package com.dgshanger.sanhxiaofeisc.ui.home.utils;

/**
 * Created by JacobHHH on 2018/5/7.
 * AscII转换工具类
 */

public class AscIIUtils {
    public static String stringToAscii(String value)
    {
        StringBuffer sbu = new StringBuffer();
        char[] chars = value.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if(i != chars.length - 1)
            {
                sbu.append((int)chars[i]);
            }
            else {
                sbu.append((int)chars[i]);
            }
        }
        return sbu.toString();
    }

    public static String asciiToString(String value)
    {
        StringBuffer sbu = new StringBuffer();
        char[] chars = value.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            char aChar = chars[i];
            sbu.append((char) Integer.parseInt(String.valueOf(aChar)));
        }
        return sbu.toString();
    }
}
